﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using LibraryO2S;

public partial class controls_admin_ViewHelpOnline : Pages_Base
{
    private static DataSet objDS = new DataSet();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (divMessage.InnerHtml != "")
            divMessage.InnerHtml = "";
        if (!IsPostBack)
            loadHelp();
    }
    private void loadHelp()
    {
        try
        {
            objDS = new DataSet("helponline");
            objDS.ReadXml(Server.MapPath("../upload/xml/helponline.xml"));
            DataTable objDT = objDS.Tables[0];
            if (objDT.Rows.Count > 0)
            {
                rptHelpOnline.DataSource = objDT;
                rptHelpOnline.DataBind();
            }
            else
                divMessage.InnerHtml = O2S_Message.Warning("Cảnh Báo", "Chưa có bản ghi trợ giúp nào !");
        }
        catch (Exception ex)
        {
            divMessage.InnerHtml = O2S_Message.Warning("Lỗi", "Phát hiện lỗi: <br />" + ex.Message);
        }
    }

    protected void rptHelpOnline_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        string command = e.CommandName;
        if (command.Equals("edit"))
            Response.Redirect("default.aspx?module=HelpOnline&index=" + (e.Item.ItemIndex).ToString());
        else
        {
            objDS.Tables[0].Rows.RemoveAt(e.Item.ItemIndex);
            objDS.WriteXml(Server.MapPath("../upload/xml/helponline.xml"));
        }
        loadHelp();
    }
}
